package com.qy.service.impl;

import com.qy.dao.ApplyMapper;
import com.qy.dao.EvaluationMapper;
import com.qy.dao.PolicyMapper;
import com.qy.model.Apply;
import com.qy.model.Evaluation;
import com.qy.model.Policy;
import com.qy.service.ApplyService;
import com.qy.base.core.AbstractService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;
import java.util.Map;


/**
 * Created by zaq on 2018/07/10.
 */
@Service
@Transactional
public class ApplyServiceImpl extends AbstractService<Apply> implements ApplyService {
    @Resource
    private ApplyMapper qyApplyMapper;
    @Resource
    private PolicyMapper policyMapper;
    @Resource
    private EvaluationMapper evaluationMapper;

    @Override
    public List<Apply> selectApplyListByUserId(Apply apply) {
        return qyApplyMapper.selectApplyListByUserId(apply);
    }

    @Override
    public List<Apply> applyList(Apply apply) {
        return qyApplyMapper.applyList(apply);
    }

    @Override
    public Map seeApply(Integer id) {
        Apply apply = qyApplyMapper.seeApply(id);
        Policy policy = policyMapper.seePolicy(apply.getPolicy_id());
        Evaluation evaluation = evaluationMapper.seeEvaluation(apply.getEvaluation_id());
        Map<String,Object> map = new HashMap<>();
        map.put("policy",policy);
        map.put("evaluation",evaluation);
        return map;
    }

    @Override
    public List<Apply> selectApplyListById(Policy policy) {
        return qyApplyMapper.selectApplyListById(policy);
    }
}
